<template>
  <div class='container'>
  <el-dialog title="题目预览" :visible="ShowDialog" @close='closeDialogForm' >
  <el-form  style="width:100%">
  <el-row>
  <el-col :span="6">【题型】：{{questionTypes}}</el-col>
  <el-col :span="6">【编号】：{{previewList.id}}</el-col>
  <el-col :span="6">【难度】：{{difficuType}}</el-col>
  <el-col :span="6">【标签】：{{previewList.tags}}</el-col>
  </el-row>
 <el-row>
  <el-col :span="6">【学科】：{{previewList.subject}}</el-col>
  <el-col :span="6">【目录】：{{previewList.catalog}}</el-col>
  <el-col :span="6">【方向】：{{previewList.direction}}</el-col>
  </el-row><hr>
<el-row>
  <el-col :span="24">【题干】：
    <div v-html='previewList.question' style="color:blue"></div>
    <div v-if="flag==='radio'">
      单选题 选项：（以下选中的选项为正确答案）<br>
      <div v-for="(item,index) in options" :key="item.id">
      <el-radio v-model="radio" :label="index" :disabled='radio!==index'>{{item.title}}</el-radio>
      </div>
    </div>
       <div v-else-if="flag==='check'">
      多选题 选项：（以下选中的选项为正确答案）<br>
      <div v-for="item in options" :key="item.id" style="line-height:35px">
      <el-checkbox :label="item.title" :checked='item.isRight===1' :disabled='item.isRight!==1'></el-checkbox>
      </div>
    </div>
      <div v-else>
    </div>
  </el-col>
</el-row><hr>
<el-row>
    <el-col :span="24">【参考答案】： <el-button type="danger" @click="videoShow=!videoShow">视频答案预览</el-button>
      <div v-if="videoShow" style="margin-top: 20px">
        <video
            :src="previewList.videoURL"
            autoplay
            controls="controls"
            style="width: 300px"
            ></video>
      </div>
  </el-col>
</el-row><hr>
<el-row>
  <el-col :span="24">【答案解析】：<span v-html="previewList.answer"></span> </el-col>
</el-row><hr>
<el-row>
  <el-col :span="24">【题目备注】：{{previewList.remarks}}</el-col>
</el-row>
   <el-form-item >
   <div style="float:right">
    <el-button type="primary" @click="closeDialogForm">关闭</el-button>
   </div>
     </el-form-item>
   </el-form>
</el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    dialogFormVisible: {
      type: Boolean,
      default: false
    },
    ShowDialog: {
      type: Boolean,
      required: true
    },
    previewList: {
      type: Object,
      required: true
    },
    options: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      dialogTableVisible: false,
      checkbox: [],
      videoShow: false
    }
  },
  methods: {
    closeDialogForm () {
      this.$emit('update:ShowDialog', false)
      this.videoShow = false
    }
  },
  computed: {
    difficuType () {
      if (this.previewList.difficulty === 1) {
        return '简单'
      } else if (this.previewList.difficulty === 2) {
        return '一般'
      } else {
        return '困难'
      }
    },
    questionTypes () {
      if (this.previewList.questionType === '1') {
        return '单选'
      } else if (this.previewList.questionType === '2') {
        return '多选'
      } else {
        return '简答'
      }
    },
    flag () {
      if (this.previewList.questionType === '1') {
        return 'radio'
      } else if (this.previewList.questionType === '2') {
        return 'check'
      } else {
        return 'idea'
      }
    },
    radio () {
      if (this.options[0].isRight === 1) {
        return 0
      } else if (this.options[1].isRight === 1) {
        return 1
      } else if (this.options[2].isRight === 1) {
        return 2
      } else {
        return 3
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.box-card{
  width: 50%;
  height: 500px;
  background-color: pink;
}
::v-deep{
  .el-col-6{
    line-height: 30px;
  }
  .el-col-24{
    line-height: 30px;
  }
}
</style>
